#!/bin/bash
beesu_requires "mate-terminal" "mate-terminal"
base="`echo $CAJA_SCRIPT_CURRENT_URI | cut -d'/' -f3- | sed 's/%20/ /g'`"
if [[ -n "$CAJA_SCRIPT_SELECTED_FILE_PATHS" ]]
then
    if [ `echo -ne "$CAJA_SCRIPT_SELECTED_FILE_PATHS" | wc -l` -eq "1" ]
    then
        quoted=$(echo -e "$CAJA_SCRIPT_SELECTED_FILE_PATHS" | 
                 head -n 1 |
                 awk 'BEGIN { FS = "\n" } { printf "\"%s\"", $1 }' | sed -e s#\"\"##)
        # beesu - mate-terminal --working-directory="$base" -e "$quoted"
        # We now have to place beesu at the end because mate-terminal throws dbus errors and fails otherwise.
        mate-terminal --working-directory="$base" -e "beesu '$quoted'"
    else
        zenity --info --title="Execute Script" --text="I won't run more than one script at once."
    fi
fi
# F12
/bin/true
